package com.lion.logclientstarter;

import com.lion.logclientstarter.service.LogAspectj;
import com.lion.logclientstarter.service.LogClient;
import com.lion.logclientstarter.service.impl.LogClientImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.task.TaskExecutor;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

/**
 * @Author linbin
 * @Description
 * config.person.enable=true，havingValue=“true”，加载Bean
 *
 * config.person.enable=false，havingValue=“false”，加载Bean
 *
 * config.person.enable=ok，havingValue=“ok”，加载Bean
 *
 * config.person.enable=false，havingValue=“true”，不加载Bean
 *
 * config.person.enable=ok，havingValue=“no”，不加载Bean
 *
 * 当然havingValue也可以不设置，只要配置项的值不是false或“false”，都加载Bean
 *
 * config.person.enable=ok，不设置havingValue，加载Bean
 *
 * config.person.enable=false，不设置havingValue，不加载Bean
 **/
@EnableAsync
@Configuration
@ConditionalOnProperty(prefix = "lion.log", name = "enable",havingValue = "true")
public class LogClientConfiguration {


    /**
     * 业务数据的操作客户端
     *  ConditionalOnMissingBean 预留 供上层用户注入可依据自身业务情况处理所需的操作方案
     * @return
     */
    @Bean
    @ConditionalOnMissingBean
    public LogClient logClient() {
        return new LogClientImpl();
    }

    /**
     * 日志的有关切片AOP
     */
    @Bean
    public LogAspectj logAspectj() {
        return new LogAspectj();
    }


}
